//package com.navi.loaddata.loadService.impl.measureData.array;
//
//import com.navi.loaddata.core.gpEntity.MOpeD;
//import com.navi.loaddata.core.gpEntity.array.WppAdefectGlassF;
//import com.navi.loaddata.core.mysqlEntity.EtlConfD;
//import com.navi.loaddata.core.repository.impl.GreenPlumRepositoryImpl;
//import com.navi.loaddata.core.util.LoggerUtil;
//import com.navi.loaddata.core.util.ProcessUtil;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import com.navi.loaddata.core.gpEntity.array.WppAdefectF;
//import com.navi.loaddata.core.gpEntity.array.WppAdefectPanelF;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//import static com.navi.loaddata.core.constant.GenericDef.*;
//
//@Service
//@Transactional(transactionManager = "secondaryPlatformTransactionManager")
//public class LoadDefectInfoServiceARRAY {
//    private static final Logger logger = LoggerFactory.getLogger(LoadDefectInfoServiceARRAY.class);
//    private LoggerUtil loggerUtil = new LoggerUtil(this.getClass());
//
//    private static final Map<String, String> glassNameMap;
//    private static final Map<String, String> glassEntityNameMap;
//
//    static {
//        glassNameMap = new HashMap<>();
//        glassNameMap.put(SHOP_ARY, "sor.wpp_adefect_glass_f");
//        glassNameMap.put(SHOP_CF, "sor.wpp_fdefect_glass_f");
//        glassNameMap.put(SHOP_OC, "sor.wpp_cdefect_glass_f");
//
//        glassEntityNameMap = new HashMap<>();
//        glassEntityNameMap.put(SHOP_ARY, "WppAdefectGlassF");
//        glassEntityNameMap.put(SHOP_CF, "WppCdefectGlassF");
//        glassEntityNameMap.put(SHOP_OC, "WppFdefectGlassF");
//    }
//
//    @Autowired
//    private GreenPlumRepositoryImpl dao2;
//
//    //只取A开头的glass
//    public List<WppAdefectGlassF> loadGlassInfo(EtlConfD etlConfD) {
//        StringBuffer hql = new StringBuffer();
//        hql.append("FROM WppAdefectGlassF WHERE evtTimestamp < '").append(etlConfD.getEtlTimestamp())
//                .append("' and dbTimestamp >= '").append(etlConfD.getRunStartTimestamp())
//                .append("' and dbTimestamp<'").append(etlConfD.getRunEndTimestamp())
//                .append("' and realFlg='Y' and glassId like 'A%'");
//        hql.append(ProcessUtil.getOpeHql(etlConfD.getOpe()));
//        hql.append(" order by evtTimestamp ");
//
//        return dao2.list(WppAdefectGlassF.class, hql.toString());
//    }
//
//    public List<WppAdefectPanelF> loadPanelInfo(EtlConfD etlConfD, WppAdefectGlassF glass) {
//
//        StringBuffer hql = new StringBuffer();
//        hql.append("FROM WppAdefectPanelF WHERE evtTimestamp = '")
//                .append(glass.getEvtTimestamp())
//                .append("' and realFlg='Y' ")
//                .append(" and glassId = '").append(glass.getGlassId()).append("' ")
//                .append(" and jgeCnt = '").append(glass.getJgeCnt()).append("' ");
//        hql.append(ProcessUtil.getOpeHql(etlConfD.getOpe()));
//        return dao2.list(WppAdefectPanelF.class, hql.toString());
//    }
//
//    public List<WppAdefectF> loadDefectInfo(EtlConfD etlConfD, WppAdefectGlassF glass) {
//
//        StringBuffer hql = new StringBuffer();
//        hql.append("FROM WppAdefectF WHERE evtTimestamp = '")
//                .append(glass.getEvtTimestamp())
//                .append("' and realFlg='Y' ")
//                .append(" and glassId = '").append(glass.getGlassId()).append("' ")
//                .append(" and jgeCnt = '").append(glass.getJgeCnt()).append("' ");
//        hql.append(ProcessUtil.getOpeHql(etlConfD.getOpe()));
//
//        return dao2.list(WppAdefectF.class, hql.toString());
//    }
//
//
//    public Map<String, String> loadMOpeDInfo(EtlConfD etlConfD) {
//        Map<String, String> mapOpe = new HashMap<>();
//        List<MOpeD> opeList = new ArrayList<>();
//        StringBuffer hql = new StringBuffer();
//        hql.append("FROM MOpeD WHERE 1=1 ");
//        hql.append(ProcessUtil.getOpeHql(etlConfD.getOpe()));
//        hql.append(" order by evtTimestamp");
//        opeList = dao2.list(MOpeD.class, hql.toString());
//
//        opeList.forEach(opeFormat -> {
//            if (!StringUtils.isEmpty(opeFormat.getOpeDefFormat())) {
//                mapOpe.put(opeFormat.getOpeId(), opeFormat.getOpeDefFormat());
//            } else {
//                mapOpe.put(opeFormat.getOpeId(), null);
//            }
//        });
//        return mapOpe;
//    }
//
//}
